<?php

/**
 * @author Terry & 千里孤坟
 * @copyright 2009
 */

class EventSkillStatus {
	public function __construct(){
		$this->id = -1;
		$this->on = 0;		//开关
		$this->name = "基类";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
	}

        public function checkex($a) {
                if(!isset($this->ex) && isset($this->excid) && in_array($a->cid,$this->excid)) {
                        $this->name = "<font color=blue>EX".$this->name."</font>";
                        $this->ex = 1;
                        $this->exskset();
                }   
        }

        public function exskset() {
                return 1;
        }  
	
	public function action($a,$b) {				
		return 0;
	}
	
	public function cancel($a) {
		$a->eventskill_status[$this->id]->on = 0;
		$a->eventskill_status[$this->id]->n = 0;
	}		
}

class ShouriNoXichui extends EventSkillStatus {
	public function __construct(){
		$this->id = 1;
		$this->on = 0;		//开关
		$this->name = "勝利の息吹";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
		$this->v = 0.25;
		$this->excid = array(34);
	}

	public function exskset() {
		$this->v = 0.45;
	}	

	public function action($a,$b) {
		$this->checkex($a);
		if($a->hp > 0) {
			$_SESSION['show'] .= $a->name."勝利の息吹发动，HP/SP回复。<br>";
			$a->hp += round($a->mxhp*$this->v);
			$a->sp += round($a->mxsp*$this->v);
			$a->tp += round($a->mxtp*$this->v);
			
			if($a->hp > $a->mxhp) $a->hp = $a->mxhp;
			if($a->sp > $a->mxsp) $a->sp = $a->mxsp;
			if($a->tp > $a->mxtp) $a->tp = $a->mxtp;		
		}						
		return 0;
	}
}

class ShouriNoShout extends EventSkillStatus {
	public function __construct(){
		$this->id = 2;
		$this->on = 0;		//开关
		$this->name = "勝利の雄叫";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
		$this->v = 0.4;
		$this->excid = array(113);
	}
	
	public function exskset() {
		$this->v = 0.6;
	}	

	public function action($a,$b) {
		$this->checkex($a);
		if($a->hp > 0) {
			$_SESSION['show'] .= $a->name."勝利の雄叫发动，HP/SP大量回复。<br>";
			$a->hp += round($a->mxhp*$this->v);
			$a->sp += round($a->mxsp*$this->v);
			$a->tp += round($a->mxtp*$this->v);
			
			if($a->hp > $a->mxhp) $a->hp = $a->mxhp;
			if($a->sp > $a->mxsp) $a->sp = $a->mxsp;
			if($a->tp > $a->mxtp) $a->tp = $a->mxtp;		
		}						
		return 0;
	}
}

class OnceDance extends EventSkillStatus {
	public function __construct(){
		$this->id = 3;
		$this->on = 1;		//开关
		$this->name = "瞬転の舞踏";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}

	public function action($a,$b,$sk) {
		if(CalHelper::ifgroupskill($a) == 14 && $b->hp > 0 && $b->hited && $sk->oap >= 10) {
			$tmp = mt_rand(1,100);
			$_SESSION['result'] .= $this->name."发动乱数：$tmp<br>";
			if(25 >= $tmp) {
				$_SESSION['show'] .= $a->name."发动".$this->name."，".$b->name."上升状态被打消<br>";
				StatusHelper::goodestroy($b);
			}
		}
	}
}

class Mistilteinn extends EventSkillStatus { 
	public function __construct(){
		$this->id = 4;
		$this->on = 0;		//开关
		$this->name = "ミストルティン";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}

	public function action($sk,$a,$b) {
		if($b->defskill_status[3]->on == 1 && $sk->puredead != 1) {
			$sk->res = ($sk->atk_type == 8) ? 1 : 1.25;
			$_SESSION['result'] .= $b->name."处于防御状态，破防道具效果发动<br>";
		} elseif($sk->res == 1.25) {
			$sk->res = 1;
			$_SESSION['result'] .= $b->name."未处于防御状态，无法命中弱点<br>";
		}
	}
}

class Alive extends EventSkillStatus { 
	public function __construct(){
		$this->id = 5;
		$this->on = 0;		//开关
		$this->name = "生還";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class ZionAlive extends EventSkillStatus { 
	public function __construct(){
		$this->id = 6;
		$this->on = 0;		//开关
		$this->name = "大生還";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class PoisonGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 7;
		$this->on = 0;		//开关
		$this->name = "毒防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class OldGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 8;
		$this->on = 0;		//开关
		$this->name = "老化防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class CloseGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 9;
		$this->on = 0;		//开关
		$this->name = "封印防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class PalaGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 10;
		$this->on = 0;		//开关
		$this->name = "麻痹防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class QuickRecover extends EventSkillStatus {
	public function __construct(){
		$this->id = 11;
		$this->on = 0;		//开关
		$this->name = "急速回复";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class BodyGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 12;
		$this->on = 0;		//开关
		$this->name = "仁王立";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class HighGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 13;
		$this->on = 0;		//开关
		$this->name = "激昂防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class LureGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 14;
		$this->on = 0;		//开关
		$this->name = "魅惑防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class TerrorGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 15;
		$this->on = 0;		//开关
		$this->name = "恐怖防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class ConfuseGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 16;
		$this->on = 0;		//开关
		$this->name = "混乱防御";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class EscapeSpeedUp extends EventSkillStatus {
	public function __construct(){
		$this->id = 17;
		$this->on = 0;		//开关
		$this->name = "逃走加速";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class MetalGuard extends EventSkillStatus {
	public function __construct(){
		$this->id = 18;
		$this->on = 0;		//开关
		$this->name = "不动心";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class ChaosBeam extends EventSkillStatus {
	public function __construct(){
		$this->id = 19;
		$this->on = 0;		//开关
		$this->name = "混沌波动";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class GangesS extends EventSkillStatus {
	public function __construct(){
		$this->id = 20;
		$this->on = 0;		//开关
		$this->name = "恒河沙";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
	}
}

class AllRes extends EventSkillStatus {
	public function __construct(){
		$this->id = 21;
		$this->on = 0;		//开关
		$this->name = "全門耐性";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
		$this->v = 0.3;
		$this->excid = array(146);
		$this->started = 0;
	}

	public function exskset() {
		$this->v = 0.5;
	}

	public function action($a) {
		if($a->defafter_status[2]->on == 1) {
			$this->cancel($a);
			return 0;
		}
		$this->checkex($a);
		if($a->hp <= round($a->mxhp*$this->v) && $a->hp > 0 && $a->before_status[71]->on != 1 && $this->started == 0) {
			$this->started = 1;
			$_SESSION['show'] .= $a->name."发动".$this->name."(效果由裁判判断)<br>";
			$a->before_status[71]->on = 1;
		}
	}

}

class TrueAllRes extends EventSkillStatus {
	public function __construct(){
		$this->id = 22;
		$this->on = 0;		//开关
		$this->name = "真·全門耐性";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
		$this->started = 0;
	}

	public function action($a) {
		if($a->defafter_status[2]->on == 1) {
			$this->cancel($a);
			return 0;
		}
		if($a->hp <= round($a->mxhp/2) && $a->hp > 0 && $this->started == 0) {
			$_SESSION['show'] .= "这就是……生命的奔流！<br>";
			CalHelper::cgdisplay('2O_1.jpg');
			$_SESSION['show'] .= $a->name."发动".$this->name."(效果由裁判判断)<br>";
			$this->started = 1;
			//$a->before_status[72]->on = 1;
		}
	}

}

class DeathRes extends EventSkillStatus {
	
	public function __construct(){
		$this->id = 23;
		$this->on = 0;		//开关
		$this->name = "テトラジャ";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}
}

class RonWeapon extends EventSkillStatus {

	public function __construct(){
		$this->id = 24;
		$this->on = 0;		//开关
		$this->name = "ロンゴミアント";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
		$this->v = 0.25;
	}

	public function action($a,$b) {
		if($a->eventskill_status[1]->on == 1 || $a->eventskill_status[2]->on == 1) return 0;
		$tmp = mt_rand(1,100);
		$_SESSION['result'] .= $this->name."发动乱数：$tmp<br>";
		if(25 >= $tmp) {
			if($a->hp > 0) {
				$_SESSION['show'] .= $a->name."ロンゴミアント特殊效果发动，HP/SP回复。<br>";
				$a->hp += round($a->mxhp*$this->v);
				$a->sp += round($a->mxsp*$this->v);
				$a->tp += round($a->mxtp*$this->v);
			
				if($a->hp > $a->mxhp) $a->hp = $a->mxhp;
				if($a->sp > $a->mxsp) $a->sp = $a->mxsp;
				if($a->tp > $a->mxtp) $a->tp = $a->mxtp;		
			}
		}
		return 0;
	}
}

class HellMask extends EventSkillStatus {
	
	public function __construct(){
		$this->id = 25;
		$this->on = 0;		//开关
		$this->name = "地獄のマスク";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}
}

?>
